const htmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const { merge } = require("webpack-merge");
const baseConfig = require("./webpack.base.config");

const devConfig = {
  output: {
    path: path.resolve(__dirname, "./dev"),
    filename: "[name]-[chunkhash:6].js",
  },
  mode: "development",
  module: {
    rules: [
      {
        test: /\.less$/,
        include: path.resolve(__dirname, "./src"),
        use: ["style-loader", "css-loader", "postcss-loader", "less-loader"],
      },
    ],
  },

  devtool: "sourcemap", //定位错误
  devServer: {
    contentBase: "./dist", //这个一般都不会去改的
    port: 666, //服务器端口
    open: true, //自动打开浏览器的窗口
    // 配置代理 处理跨域
    proxy: {
      "/api": {
        target: "http://localhost:777",
      },
    },
  },
};

module.exports = merge(baseConfig, devConfig);
